package com.cuit.riskassessment.service.impl;

import javax.annotation.Resource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.cuit.riskassessment.dao.ru.RuMapper;
import com.cuit.riskassessment.service.RuService;
import com.cuit.riskassessment.vo.RuParam;
/**
 * 
 * @author Yang_Zhiqin-pc
 *
 */
@Service(value="ruService")
public class RuServiceImpl implements RuService {

	@Autowired
	@Resource(name="ruMapper")
	private RuMapper ruMapper;
	@Override
	public boolean addOrUpdateRu1(RuParam ru) {
		// TODO Auto-generated method stub
		boolean flag = false;
		//Integer i = this.ruMapper.isRuExist(ru.getProjid());
		if(this.ruMapper.isRuExist(ru.getProjid())<1)
		{
			flag = this.ruMapper.addRu1(ru)>0?true:false;
		}else
		{
			flag = this.ruMapper.updateRu1(ru)>0?true:false;
		}
		return flag;
	}

	@Override
	public boolean addOrUpdateRu2(RuParam ru) {
		// TODO Auto-generated method stub
		boolean flag = false;
		//Integer i = this.ruMapper.isRuExist(ru.getProjid());
		if(this.ruMapper.isRuExist(ru.getProjid())<1)
		{
			flag = this.ruMapper.addRu2(ru)>0?true:false;
		}else
		{
			flag = this.ruMapper.updateRu2(ru)>0?true:false;
		}
		return flag;
	}


	@Override
	public RuParam getRu1(Integer projid) {
		// TODO Auto-generated method stub
		return this.ruMapper.getRu1(projid);
	}

	@Override
	public RuParam getRu2(Integer projid) {
		// TODO Auto-generated method stub
		return this.ruMapper.getRu2(projid);
	}

}
